///*
// * Copyright (C) 2012 mAPPn.Inc
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// *      http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//package com.mol.market.demo.ui;
//
//import android.content.Intent;
//import android.os.Bundle;
//import android.support.v4.content.Loader;
//import android.widget.CompoundButton;
//import android.widget.CompoundButton.OnCheckedChangeListener;
//import android.widget.RadioButton;
//import com.mol.market.Constants;
//import com.mol.market.R;
//import com.mol.market.common.network.ApiResponse;
//import com.mol.market.common.network.MarketAPI;
//import com.mol.market.common.util.ScreenRules;
//import com.mol.market.common.util.ScreenRules.Rules;
//import com.mol.market.common.util.Utils;
//import com.mol.market.ui.core.GridAdapter;
//import com.mol.market.ui.core.LazyLoadAdapter;
//import com.mol.market.ui_v4.ProductDetailActivity;
//
//import java.util.HashMap;
//
//
///**
// * 汉化应用排行列表
// *
// * @author Chaos	
// * @date 2013-1-16
// */
//public class LocalizationFragment extends RankFragment implements OnCheckedChangeListener {
//
//    
//    @Override
//    protected void handleRadionButton(RadioButton rb1, RadioButton rb2, RadioButton rb3) {
//        rb1.setText("推荐");
//        rb2.setText("汉化游戏");
//        rb3.setText("汉化应用");
//    }
//
//    @Override
//    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//        super.onCheckedChanged(buttonView, isChecked);
//        switch (buttonView.getId()) {
//            case R.id.rb_game:
//                Utils.trackEvent(getApplicationContext(), "汉化", "推荐");
//                break;
//            case R.id.rb_app:
//                Utils.trackEvent(getApplicationContext(), "汉化", "汉化游戏");
//                break;
//            case R.id.rb_ebook:
//                Utils.trackEvent(getApplicationContext(), "汉化", "汉化应用");
//                break;
//        }
//    }
//
//    @Override
//    public Loader<ApiResponse> onCreateLoader(int arg, Bundle args) {
//        switch (arg) {
//        case R.id.rb_game:
//            return MarketAPI.initLocalRecommend(getApplicationContext(), 
//                    getStart(), getSize());
//
//        case R.id.rb_app:
//            return MarketAPI.initRankByCategoryLoader(getSherlockActivity(),
//                    getStart(), getSize(), Constants.CATEGORY_GAME);
//
//        case R.id.rb_ebook:
//            return MarketAPI.initRankByCategoryLoader(getSherlockActivity(), 
//                    getStart(), getSize(), Constants.CATEGORY_APP);
//        default:
//            return MarketAPI.initLocalRecommend(getApplicationContext(), 
//                    getStart(), getSize());
//        }
//    }
//
//    @Override
//    protected LazyLoadAdapter initLazyLoadAdapter() {
//        GridAdapter adapter = new GridAdapter(
//                this,
//                null,
//                ScreenRules.getLayout(getWidthMatching(), Rules.Download),
//                new String[]{
//                        Constants.KEY_PRODUCT_ICON_URL,
//                        Constants.KEY_PRODUCT_NAME,
//                        Constants.KEY_PRODUCT_AUTHOR,
//                        Constants.KEY_PRODUCT_IS_STAR,
//                        Constants.KEY_PRODUCT_DOWNLOAD,
//                        Constants.KEY_PRODUCT_SIZE,
//                        Constants.KEY_PRODUCT_DOWNLOAD_COUNT,
//                },
//                new int[]{
//                        R.id.iv_logo,
//                        R.id.tv_name,
//                        R.id.tv_description,
//                        R.id.iv_star,
//                        R.id.tv_download,
//                        R.id.tv_size,
//                        R.id.tv_downloading,
//                });
//        
//        adapter.setNumColumns(ScreenRules.getNumColumns(getWidthMatching(), Rules.Download));
//
//        adapter.setOnItemClickListener(new GridAdapter.OnItemClickListener() {
//            @Override
//            public void onItemClick(int pos, int realPos, HashMap<String, Object> item) {
//                String pid = (String) item.get(Constants.KEY_PRODUCT_ID);
//                String name = (String) item.get(Constants.KEY_PRODUCT_NAME);
//                String sourceType = (String) item.get(Constants.KEY_PRODUCT_SOURCE_TYPE);
//                Intent detailIntent = new Intent(getActivity(), ProductDetailActivity.class);
//                detailIntent.putExtra(Constants.EXTRA_PRODUCT_ID, pid);
//                detailIntent.putExtra(Constants.EXTRA_PRODUCT_NAME, name);
//                detailIntent.putExtra(Constants.EXTRA_SOURCE_TYPE, sourceType);
//                getActivity().startActivity(detailIntent);
//                switch (mCheckId) {
//                    case R.id.rb_game:
//                        Utils.trackEvent(getApplicationContext(), "汉化", "推荐tab-进入详情页");
//                        break;
//                    case R.id.rb_app:
//                        Utils.trackEvent(getApplicationContext(), "汉化", "汉化游戏tab-进入详情页");
//                        break;
//                    case R.id.rb_ebook:
//                        Utils.trackEvent(getApplicationContext(), "汉化", "汉化应用tab-进入详情页");
//                        break;
//                }
//            }
//        });
//        
//        adapter.setProductList();
//
//        return adapter;
//    }
//
//}
